//递归求解汉诺塔问题

public class Test23 {
    public static void main(String[] args) {
        HanoiTower(3,"A","B","C");
    }
    //n为盘子的数目，from为原始柱子，to为辅助柱子，help为目标珠子
    private static void HanoiTower(int n, String from, String to, String help) {
        if(n==1){
            System.out.println("移动"+n+"从"+from+"至"+to);
            return;
        }
        HanoiTower(n-1,from,help,to);//先把前n-1个盘子搬到辅助空间上去
        System.out.println("移动"+n+"从"+from+"至"+to);//n可以顺利到达目标盘子
        HanoiTower(n-1,help,to,from);//让n-1从辅助空间回到源空间上去
    }
}
